package top.lywivan.search.controller;

import top.lywivan.common.entity.Result;
import top.lywivan.common.pojo.Question;
import top.lywivan.search.service.SearchQuestionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/question")
public class SearchQuestionController {
    @Autowired
    private SearchQuestionService searchQuestionService;

    @PostMapping("/add")
    public Result addQuestion(@RequestBody Question question){
        //模拟熔断降级
        /*try {
            TimeUnit.SECONDS.sleep(2);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }*/
        searchQuestionService.addQuestion(question);
        return new Result(true,"远程调用添加成功");
    }
}
